package com.threadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by yijy on 2017/9/18.
 */
public class CacheThreadPoolTest {
    public static void main(String[] args) {
        ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
        for(int i=0;i<20;i++){
            final int index=1;
            cachedThreadPool.execute(()-> {
                try {
                    Thread.sleep(index*100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+":"+index);
            });
        }
    }
}
